package com.useeinfo.oa.common.utils.httpJson;

import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * @author geniusj
 * @email 975473185@qq.com
 * @date 2018/8/20  下午2:22
 */
public class MyJudgmentJson extends DefaultJudgmentJson {

    private static final String API = "/api/";


    @Override
    public boolean isJson(HttpServletRequest request) {
        return  super.isJson(request) || isApi(request);
    }

    /**
     * 用与判断是否时api接口进来的请求
     * @param request request请求
     * @return
     */
    private static boolean isApi(HttpServletRequest request){
        String targetUrl = request.getRequestURI();
        return  StringUtils.startsWithIgnoreCase(targetUrl, API);
    }
}
